#ifndef __ENCODING_CONVERTOR_H__
#define __ENCODING_CONVERTOR_H__

#include <string>
#include <iconv.h>

class EncodingConvertor
{
public:
	// "UTF-8", "GBK", "GB2312", "GB18030"
	EncodingConvertor(const char* toEncoding, const char* fromEncoding);

	~EncodingConvertor();

    std::string Convert(const char* in, size_t in_len);
	std::string Convert(const char* in);
    std::string Convert(const std::string& in);

private:
	iconv_t _iconv;
};

#define GB2312ToUTF8(s) EncodingConvertor("UTF-8", "GB2312").Convert(s)

#endif // __ENCODING_CONVERTOR_H__